package day03.text01;

import java.io.*;
import java.net.Socket;

/**
 * @author lc
 */
public class Client {
    public static void main(String[] args) throws IOException {


        //创建对象，开始发数据
        Socket socket = new Socket("127.0.0.1", 9999);
        OutputStream os = socket.getOutputStream();
        //从a.txt读取文件,就文件通过网络os发送出去
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("D:\\Java\\group5InClass27\\a.txt"));
        int i;
       while ((i=bis.read())!=-1){
           os.write(i);
       }
       //执行shutdownOutput告诉服务端，文件已传完
       socket.shutdownOutput();
       //接收服务端发来的返回消息

        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String b;
        while ((b=br.readLine())!=null){
            System.out.println(b);
        }


      bis.close();
        os.close();
      socket.close();
    }
}
